package com.example.web.exception;

import com.example.common.utils.result.ResultBO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <p>
 *
 * </p>
 *
 * @author 12071
 * @date 2022/8/1 16:16
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理RequestBody请求参数校验(实体对象)
     */
    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public ResultBO validExceptionHandler(Exception e) {
        log.error("?????????? 参数异常: {}", e.getMessage());
        return ResultBO.error(e.getMessage()) ;
    }
}
